package com.example.gitstudy.loginfo;

import com.example.gitstudy.config.ResponseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author hwj
 * @date 2023/1/16 14:43
 * @描述；
 */
@RestController
@RequestMapping("getIpInfo")
public class LogIpController {


    @GetMapping("ipInfo")
    public ResponseResult getIpInfo(HttpServletRequest request){

        HashMap<String,String> map = new HashMap<>();
        String address = IpUtil.getAddress("123.232.102.18");
        String localIP = IpUtil.getLocalIP();
        String ipAddr = IpUtil.getIpAddr(request);
        map.put("address",address);
        map.put("localIP",localIP);
        map.put("ipAddr",ipAddr);

        return  new ResponseResult(200,"ip相关信息",map);
    }




}
